<template>
	<view>
		<view class="page">
			<view class="example-body">
				<uni-nav-bar background-color="#003466" color="#ffffff" :status-bar="true" @click-left="back" left-icon="arrowleft" style="position: relative;">
					<view class="flex-item" style="position: absolute;left: 0;right: 0;margin: auto;width: 50%;">值班计划列表</view>
					<view class="flex-item flex-right"><view class="duty-schright btn" @click="open"></view></view>
				</uni-nav-bar>
			</view>

			<!-- 弹窗日历 -->
			<uni-calendar ref="calendar" :start-date="startDate" :end-date="endDate" :date="date" :selected="selected" @confirm="confirm" @change="change" />

			<view class="duty-container">
				<view class="duty-schtitle" v-for="(items, index) in listData" :key="index">
					<view class="sch-contaier" v-show="items.isLeader == '001'">
						<view class="duty-nametitle"><image src="../../../static/images/wind-logopeople.png" mode=""></image></view>
						<view class="duty-righttitle">
							<!-- <view> -->
							<view class="right-titlename">{{ items.militaryName }}</view>
							<view class="right-titletime">{{ items.dutyPeriod }}</view>
							<!-- </view> -->
							<view class="right-bottomeopt">
								<view class="title-newstyle">
									<view class="title-dis">
										<view class="title-phone"></view>
										<view class="title-phonenumber">{{ items.phoneNumber ? items.phoneNumber : '--' }}</view>
									</view>
									<view class="title-boss">
										<view class="title-phone-new"></view>
										<view class="title-phonenumber-new">值班领导</view>
									</view>
								</view>
								<view class="title-newstyle">
									<view class="title-dis">
										<view class="title-phone-newnn"></view>
										<view class="title-phonenumber">{{ items.roomName }}</view>
									</view>
									<view class="title-boss">
										<view class="title-phonenumber-words">{{ items.dutyDate }}</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class="last-conatiner">
				<view class="list-container" v-for="(item, index) in listData" :key="index" v-show="item.isLeader == '002'">
					<view class="list-toptitle">
						<view class="toptitle-words">值班人员</view>
						<!-- 值班人员 -->
						<view class="topright-title">
							<view class="right-titlelogo"><image src="../../../static/images/huitime.png" mode=""></image></view>
							<view class="huiwords">{{ item.dutyPeriod }}</view>
						</view>
					</view>
					<view class="title-nametx">
						<view class="namtx-logo"><image src="../../../static/images/wind-logopeople.png" mode=""></image></view>
						<view class="namtx-logo-bottom">
							<view class="name-bigcontainer">
								<view class="namelogo-pic"><image src="../../../static/images/namelogopic.png" mode=""></image></view>
								<view class="namelogo-words">{{ item.militaryName }}</view>
								<!--何军-->
							</view>
							<view class="name-bigcontainer new-namebigcontainer">
								<view class="namelogo-pic"><image src="../../../static/images/huitime.png" mode=""></image></view>
								<view class="namelogo-words">{{ item.roomName }}</view>
								<!--指挥室-->
							</view>
						</view>
					</view>
				</view>
				<image src="../../../static/images/noassets.png" mode="" class="noassets" v-if="noassetsFlag"></image>
			</view>
			<!-- <view class="duty-schtitle" v-show="listData.length < 0">
				<view class="sch-contaier-new">
					暂无数据
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
import uniDrawer from '@/components/uni-drawer/uni-drawer.vue';
import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
import uniIcon from '@/components/uni-icon/uni-icon.vue';
import tools from '@/common/tools-new.js';
import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'; //弹窗日历
export default {
	data() {
		return {
			objData: [],
			noassetsFlag: false,
			listData: [],
			date: '',
			startDate: '',
			endDate: '',
			timeData: {
				clockinfo: '',
				date: '',
				fulldate: '',
				lunar: '',
				month: '',
				range: '',
				year: ''
			},
			selected: [],
			infoShow: false,

			//字典查询
			dic_data: [
				{
					name: '值班时段',
					data: []
				}
			]
		};
	},
	components: {
		uniNavBar,
		uniIcon,
		uniDrawer,
		uniCalendar
	},
	methods: {
		//头部左箭头返回父页面
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		getDate(date, AddMonthCount = 0, AddDayCount = 0) {
			if (typeof date !== 'object') {
				date = date.replace(/-/g, '/');
			}
			let dd = new Date(date);
			dd.setMonth(dd.getMonth() + AddMonthCount); // 获取AddDayCount天后的日期
			dd.setDate(dd.getDate() + AddDayCount); // 获取AddDayCount天后的日期
			let y = dd.getFullYear();
			let m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1; // 获取当前月份的日期，不足10补0
			let d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate(); // 获取当前几号，不足10补0
			return y + '-' + m + '-' + d;
		},
		/*
		 * 获取当前值班信息管理列表
		 */
		GetMaintenanceDutyInDate(dateTime) {
			let param = {
				date: dateTime
			};
			this.$api.Duty.GetMaintenanceDutyInDate(param)
				.then(res => {
					console.log(res);
					this.objData = res[1].data.result;
					// console.log(this.objData);
					this.listData = res[1].data.result;
					
					//判断有无页面数据显示，如无数据，显示暂无数据图片
					// var list = res[1].data.result
					if (this.listData == '') {
						this.noassetsFlag = true;
					} else {
						this.listData = res[1].data.result
						this.noassetsFlag = false;
					}

					//取值班时段
					this.listData.forEach((ele, index) => {
						ele.dutyPeriod = this.$helper.getTextByValue('值班时段', ele.dutyPeriod);
						ele.dutyDate = this.$helper.dateFormat(ele.dutyDate, true);
					});
				})
				.catch(res => {
					//失败进行的操作/给出提示
					uni.showToast({
						title: '接口数据请求失败',
						duration: 2000
					});
				});
		},
		/**
		 日历
		 */
		open() {
			this.reckon();
			this.$refs.calendar.open();
		},
		reckon() {},
		change(e) {
			console.log('change 返回:', e);
			this.timeData = e;
			this.infoShow = true;
		},
		confirm(e) {
			console.log('confirm 返回:', e);
			this.timeData = e;
			this.infoShow = true;
			console.log(this.timeData);
			var dateParam = this.getDate(this.timeData.fulldate, 0, 0);
			console.log('获取日期处理:' + dateParam);
			this.timeData.fulldate = dateParam;
			this.GetMaintenanceDutyInDate(this.timeData.fulldate);
			// console.log(new Date)
		},
		retract() {
			this.infoShow = !this.infoShow;
		}
	},
	onLoad: function() {
		let date = this.$helper.dateFormat(new Date(), true);
		this.GetMaintenanceDutyInDate(date);
	}
};
</script>

<style lang="less">
page {
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	background-color: #f2f2f2;
}

.flex-item {
	font-size: 20px;
	text-align: center;
}

.uni-icon {
	padding-left: 42%;
}

.uni-navbar__header-btns:last-child {
	width: 120px;
}

.uni-navbar__header-btns {
	padding: 0;
}

.example-body {
	position: relative;
	left: 0;
	right: 0;
	top: 0;
	z-index: 1;
}

.ripng {
	width: 16px;
	height: 18px;
	display: flex;
	justify-content: center;
	align-items: center;
}

.ripng image {
	max-width: 100%;
	max-height: 100%;
}

.duty-sch {
	width: 33.33333%;
	position: absolute;
	left: 0;
}

.duty-schcenter {
	width: 33.33333%;
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	margin: auto;
	text-align: center;
	line-height: 62px;
}

.duty-schright {
	width: 45px;
	height: 45px;
	position: absolute;
	right: 2%;
	background: url(../../../static/images/rlpng.png) no-repeat center center;
	background-size: 60% 60%;
}

.duty-schtitle {
	width: 94%;
	margin: 0 auto;
	margin-top: 15px;
	border-radius: 3px;
	background-color: #1f4b80;
	display: flex;
	justify-content: center;
	align-items: center;
}

.duty-righttitle {
	width: 70%;
	margin-left: 16px;
	position: relative;
	overflow: hidden;
}

.duty-nametitle {
	width: 92px;
	height: 92px;
	display: flex;
	justify-content: center;
	align-items: center;
}

.duty-nametitle image {
	max-width: 100%;
	max-height: 100%;
}

.right-titlename {
	font-size: 18px;
	position: absolute;
	left: 0;
	top: 0;
	color: #ffffff;
}

.right-titletime {
	font-size: 18px;
	position: absolute;
	right: 0;
	top: 0;
	color: #ffffff;
}

.right-bottomeopt {
	width: 100%;
	height: 52px;
	position: absolute;
	left: 0;
	bottom: 0;
}

.title-phone {
	width: 16px;
	height: 16px;
	display: flex;
	justify-content: center;
	align-items: center;
	background: url(../../../static/images/whitedphone.png) no-repeat;
	background-size: 100% 100%;
	margin-top: 2px;
}

.title-phone-newnn {
	width: 13px;
	height: 16px;
	display: flex;
	justify-content: center;
	align-items: center;
	background: url(../../../static/images/whitedwei.png) no-repeat;
	background-size: 100% 100%;
	margin-top: 2px;
}

.title-phonenumber {
	color: #ffffff;
	font-size: 16px;
	margin-left: 12px;
}

.title-dis {
	display: flex;
}

.title-newstyle {
	display: flex;
	justify-content: space-between;
	margin-top: 4px;
}

.title-boss {
	height: 24px;
	/* background: url(../../../static/images/boxshaw.png) no-repeat; */
	background-size: 100% 100%;
	position: relative;
}

.title-phone-new {
	width: 16px;
	height: 16px;
	display: flex;
	justify-content: center;
	align-items: center;
	background: url(../../../static/images/peoplename.png) no-repeat;
	background-size: 100% 100%;
	position: absolute;
	top: 3px;
	left: -16px;
}

.title-phonenumber-new {
	color: #ffffff;
	font-size: 16px;
	margin-left: 12px;
}

.title-phonenumber-words {
	color: #ffffff;
	font-size: 14px;
	height: 22px;
	line-height: 22px;
}

.sch-contaier {
	width: 94%;
	display: flex;
	padding: 3% 0;
}

.list-container {
	width: 94%;
	margin: 0 auto;
	background: #ffffff;
	margin-top: 12px;
	border-radius: 3px;
	box-shadow: 0px 1px 2px 1px rgba(30, 30, 30, 0.1);
}

.list-toptitle {
	width: 100%;
	border-bottom: 1px solid #e7e7e7;
	display: flex;
	justify-content: space-between;
}

.toptitle-words {
	font-size: 16px;
	padding: 9px 3%;
}

.topright-title {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 9px 3%;
}

.right-titlelogo {
	width: 15px;
	height: 16px;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-right: 6px;
}

.right-titlelogo image {
	max-width: 100%;
	max-height: 100%;
}

.huiwords {
	font-size: 12px;
	color: #999999;
}

.title-nametx {
	display: flex;
	padding: 14px 3%;
}

.namtx-logo {
	width: 45px;
	height: 45px;
	display: flex;
	justify-content: center;
	align-items: center;
}

.namtx-logo image {
	max-width: 100%;
	max-height: 100%;
}

.namelogo-pic {
	width: 16px;
	height: 15px;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-top: 2px;
}

.namelogo-pic image {
	max-width: 100%;
	max-height: 100%;
}

.namelogo-words {
	font-size: 14px;
	color: #999999;
	margin-left: 12px;
}

.name-bigcontainer {
	display: flex;
}

.new-namebigcontainer {
	margin-top: 6px;
}

.namtx-logo-bottom {
	margin-left: 14px;
}

.last-conatiner {
	margin-top: 22px;
}

.sch-contaier-new {
	width: 94%;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 3% 0;
	font-size: 28px;
	color: #ffffff;
}

.noassets {
	width: 300px;
	height: 300px;
	display: block;
	margin: 100px auto;
}
</style>
